package com.wallet.controller;

import com.wallet.entity.wallet;
import com.wallet.service.walletService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/wallet")
public class walletController {
    @Autowired
    private walletService service;

    @RequestMapping("/")
    public String name()
    {
        return "钱包服务！！！";
    }

    @RequestMapping("/create/{id}")
    public String create(@PathVariable("id") Integer id)
    {
        wallet w = new wallet();
        w.setBalance(0.0);
        w.setCid(id);
        service.create(w);
        return "创建钱包成功";
    }

    @RequestMapping("/find")
    public String find() throws InterruptedException {
        Thread.sleep(5000);
        return service.findAll().toString();
    }
}
